//
// Created by xili on 2024/8/6 19:50.
// Go big or go home.
//
#include <unordered_map>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maximumNumberOfStringPairs(vector<string> &words) {
        unordered_map<string, int> ump;
        int ans = 0;
        for (auto &item: words) {
            string temp = item;
            reverse(temp.begin(), temp.end());
            if (ump.count(temp)) {
                ump[temp]--;
                ans++;
            } else {
                ump[item]++;
            }
        }
        return ans;
    }
};